package com.util;


import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.*;
import java.util.Properties;

public class dbUtil {
    private static Properties properties = new Properties();
    private static Connection connection=null;
    private static Statement statement=null;

    static {
        try {
            //load文件流
            properties.load(new FileInputStream(new File("D:\\ideaDev\\ServletShoppingTest\\res\\db.properties")));
            String url = properties.getProperty("db.url");
            String username = properties.getProperty("db.username");
            String password = properties.getProperty("db.password");
            Class<?> aClass = Class.forName(properties.getProperty("db.driver"));
            connection = DriverManager.getConnection(url,username,password);
        } catch (IOException | ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        }
    }


    public static final Statement getStatement() throws ClassNotFoundException, SQLException {
        statement = connection.createStatement();
        return statement;
    }















}
